package com.enation.app.javashop.api.client;

import com.enation.app.javashop.model.promotion.pintuan.PintuanChildOrder;
import com.enation.app.javashop.model.promotion.pintuan.PintuanOrderDetailVo;
import com.enation.app.javashop.model.trade.order.dos.OrderDO;
import com.enation.app.javashop.service.trade.pintuan.PintuanOrderManager;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;

/**
 * @author fk
 * @version v2.0
 * @Description: 商品服务对外client
 * @date 2018/7/30 15:06
 * @since v7.0.0
 */
@Api(description = "商品相关API")
@RestController
@RequestMapping("/client/pintuan")
@Validated
@ApiIgnore
public class PintuanOrderClientController{

    @Autowired
    private PintuanOrderManager pintuanOrderManager;


    @GetMapping("/order/{order_sn}")
    public PintuanOrderDetailVo getMainOrderBySn(@PathVariable("order_sn") String orderSn) {
        return pintuanOrderManager.getMainOrderBySn(orderSn);
    }

    @PutMapping("/order/{order_sn}/cancel")
    public void cancelOrder(@PathVariable("order_sn") String orderSn) {
        pintuanOrderManager.cancelOrder(orderSn);
    }

    @PutMapping("/order/pay")
    public void payOrder(@RequestBody OrderDO order) {
        pintuanOrderManager.payOrder(order);
    }

    @GetMapping("/{order_id}/child-order")
    public List<PintuanChildOrder> queryChildOrderByOrderId(@PathVariable("order_id")Long pintuanOrderId) {
        return pintuanOrderManager.getPintuanChild(pintuanOrderId);
    }
}
